package com.xhsj.user.pms.patent.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xhsj.user.hr.base.BaseService;
import com.xhsj.user.hr.userInfo.dto.PageDto;
import com.xhsj.user.pms.patent.domain.TbPamOverseasApplyCountry;
import com.xhsj.user.pms.patent.mapper.TbPamOverseasApplyCountryMapper;
import com.xhsj.user.pms.patent.query.CountryListQuery;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
/**
 * <p>
 * 专利海外申请国家 服务实现类
 * </p>
 *
 * @author liuqinghua
 * @since Jun 1, 2021 6:57:01 AM
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class TbPamOverseasApplyCountryService extends BaseService<TbPamOverseasApplyCountryMapper, TbPamOverseasApplyCountry> {
    @Autowired
    private TbPamOverseasApplyCountryMapper dao;

	/**
	 * 保存
	 * @author liuqinghua
	 * @date Jun 1, 2021 6:57:01 AM
	 */
    @Override
    public boolean save(TbPamOverseasApplyCountry entity) {
        return super.save(entity);
    }

	/**
	 * 通过id获取数据
	 * @author liuqinghua
	 * @date Jun 1, 2021 6:57:01 AM
	 */
    @Override
    public TbPamOverseasApplyCountry getById(Serializable id) {
        return super.getById(id);
    }

	/**
	 * 通过id删除数据
	 * @author liuqinghua
	 * @date Jun 1, 2021 6:57:01 AM
	 */
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

	/**
	 * 分页查询数据
	 * @author liuqinghua
	 * @date Jun 1, 2021 6:57:01 AM
	 */
    public IPage<TbPamOverseasApplyCountry> selectPage(Map<String,Object> data) {
        int currentPage=1;
        if (!Objects.isNull(data.get("page"))) {
            currentPage=(Integer) data.get("page");
        }
        int pageSize=20;
        if (!Objects.isNull(data.get("size"))) {
            pageSize=(Integer) data.get("size");
        }

        TbPamOverseasApplyCountry entity = JSON.parseObject(JSON.toJSONString(data), TbPamOverseasApplyCountry.class);
        Page<TbPamOverseasApplyCountry> page = new Page(currentPage,pageSize);
        QueryWrapper<TbPamOverseasApplyCountry> wrapper = new QueryWrapper(entity);
        return super.selectPage(page, wrapper);
    }

	/**
	 * 查询所有数据
	 * @author liuqinghua
	 * @date Jun 1, 2021 6:57:01 AM
	 */
    @Override
    public List<TbPamOverseasApplyCountry> selectAll() {
        return super.selectAll();
    }


    /**
     * 海外申请 国家地区可编辑
     * @author liuqinghua
     * @date Jun 1, 2021 6:57:01 AM
     */
    public IPage<CountryListQuery> getCountryList(PageDto data) {
        Page page = new Page(data.getPage(),data.getSize());
        return dao.getCountryList(page);
    }
}
